#ifndef SLAMWIDGET_H
#define SLAMWIDGET_H

#include <QWidget>
#include <QPushButton>
#include <QProcess>
#include <QStringList>
#include <QSerialPort>

#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include "QVTKOpenGLNativeWidget.h"
#include <vtkGenericOpenGLRenderWindow.h>


#include "qrviz.hpp"

class SLAMwidget : public QWidget
{
    Q_OBJECT
public:
    explicit SLAMwidget(QWidget *parent = nullptr);
    ~SLAMwidget();

public slots:
    void onStartSLAM();
    void onPauseSLAM();
    void onStopSLAM();
    void onSaveSLAM();
    void onStartPathPlaning();
    void onSLAMClick();
    void onShowLadarImg();
    void onOpenLadar();
    void onSerialError(QSerialPort::SerialPortError e);
    void onRvizClick();
    void onOpenRviz();
    void onStopRviz();
    void onExitRviz();
    void onInitRviz();
    void onOpenPCD();



signals:
    void statusBarMessage(QtMsgType, QString);

private:
    void initUI();
    void createConn();
    void exitProcess();
    void saveMap();

     void initialVtkWidget();


private:
    QPushButton *m_btnSLAM;
    QPushButton *m_btnShowLader;
    QPushButton *m_btnOpenLader;
    QPushButton *m_btnPathPlan;
    QPushButton *m_btnOpenRviz;
    QPushButton *m_btnOpenPcd;
    QList<QProcess *> m_processes;
    QStringList *cmdList;
    bool isSLAMing = false;
    QString m_mapFullName;
    QVector<qint64> pidList;
    //QVector<qint64> m_rvizpidList;
    qint64 m_rvizPid =0;

     int m_rosVersion = 1;



     QRviz *m_rviz;
     QRviz *m_ladarRviz;


     bool m_laderRvizState =false;



     //about ladar
     QSerialPort *m_serial;



     boost::shared_ptr<pcl::visualization::PCLVisualizer> view;
     QVTKOpenGLNativeWidget *openGLWidget;
};

#endif // PATHPLANNINGWIDGET_H
